package com.xm.servlet.reception_desk.shopping_cart;

import com.xm.service.reception_desk.ShoppingCartService;
import lombok.SneakyThrows;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 获取购物车数量
 * @author 康文程
 * @date 2024-1-8 下午 02:47
 */
@WebServlet("/shopping/cart/number")
public class ShoppingCartNumber extends HttpServlet {
    /**
     * 购物车Service
     */
    private final ShoppingCartService shoppingCartService = new ShoppingCartService();
    @SneakyThrows(Exception.class)
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
        String informationId = req.getParameter("informationId");
        resp.getWriter().println(shoppingCartService.getShoppingCartQuantity(Integer.parseInt(informationId)));
    }
}
